package com.hnair;

import org.apache.log4j.Logger;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.hnair.ffp.api.siebel.read.member.MemberApi;
import com.hnair.ffp.api.siebel.read.member.request.MemberAllIdRequest;
import com.hnair.ffp.api.siebel.read.member.request.MemberRequest;
import com.hnair.ffp.api.siebel.read.member.request.MemberStatusIdRequest;
import com.hnair.ffp.api.siebel.read.member.request.QueryMobileOwnersRequest;
import com.hnair.ffp.api.siebel.read.member.response.MemberAllIdResponse;
import com.hnair.ffp.api.siebel.read.member.response.MemberResponse;
import com.hnair.ffp.api.siebel.read.member.response.MemberStatusResponse;
//import com.hnair.ffp.api.ews.member.request.QueryMobileOwnersRequest;
import com.hnair.ffp.api.siebel.read.member.response.QueryMobileOwnersResponse;
import com.springtest.Controller.login;

public class QueryMbrInfo {
	public QueryMbrInfo() {
	}
	private static Logger logger = Logger.getLogger(login.class);  
	@SuppressWarnings("unchecked")
	private static <T> T getApiService(Class<T> t, String beanName) {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
				new String[] { "dubbo-consumer.xml" });
		context.start();
		T api = (T) context.getBean(beanName); // get service invocation proxy
		return api;
	}
	
	public  String TestSerchByMobile(String StrMobileNO)
	{
		QueryMobileOwnersRequest  request = new QueryMobileOwnersRequest();
		request.setLang("zh_CN");
		request.setMobile(StrMobileNO);
		MemberApi api = getApiService(MemberApi.class, "QrtMemberApi");
		QueryMobileOwnersResponse res = api.queryMobileOwners(request);
		//logger.debug(JSONUtils.toJSONString(res));
		return JSONUtils.toJSONString(res);
	}
	
	public  String TestSerchByIDNO(String StrIDNO)
	{
		MemberAllIdRequest  request = new MemberAllIdRequest();
		request.setLang("zh_CN");
		request.setId(StrIDNO);
		MemberApi api = getApiService(MemberApi.class, "QrtMemberApi");
		MemberAllIdResponse res = api.queryMemberbyAllID(request);
		//logger.debug(JSONUtils.toJSONString(res));
		return JSONUtils.toJSONString(res);
	}
	
	public  String TestSerchByCID(String StrCID)
	{
		MemberRequest  request = new MemberRequest();
		request.setLang("zh_CN");
		request.setCid(StrCID);
		MemberApi api = getApiService(MemberApi.class, "QrtMemberApi");
		MemberResponse res = api.queryMember (request); 
		//logger.debug(JSONUtils.toJSONString(res));
		return JSONUtils.toJSONString(res);
	}
}
